// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed partial class CategorizationAnalyzerDefinition
	{
		[JsonInclude]
		[JsonPropertyName("char_filter")]
		public IEnumerable<Elastic.Clients.Elasticsearch.Analysis.CharFilter>? CharFilter { get; set; }

		[JsonInclude]
		[JsonPropertyName("filter")]
		public IEnumerable<Elastic.Clients.Elasticsearch.Analysis.TokenFilter>? Filter { get; set; }

		[JsonInclude]
		[JsonPropertyName("tokenizer")]
		public Elastic.Clients.Elasticsearch.Analysis.Tokenizer? Tokenizer { get; set; }
	}

	public sealed partial class CategorizationAnalyzerDefinitionDescriptor : SerializableDescriptorBase<CategorizationAnalyzerDefinitionDescriptor>
	{
		internal CategorizationAnalyzerDefinitionDescriptor(Action<CategorizationAnalyzerDefinitionDescriptor> configure) => configure.Invoke(this);
		public CategorizationAnalyzerDefinitionDescriptor() : base()
		{
		}

		private IEnumerable<Elastic.Clients.Elasticsearch.Analysis.CharFilter>? CharFilterValue { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.Analysis.TokenFilter>? FilterValue { get; set; }

		private Elastic.Clients.Elasticsearch.Analysis.Tokenizer? TokenizerValue { get; set; }

		public CategorizationAnalyzerDefinitionDescriptor CharFilter(IEnumerable<Elastic.Clients.Elasticsearch.Analysis.CharFilter>? charFilter)
		{
			CharFilterValue = charFilter;
			return Self;
		}

		public CategorizationAnalyzerDefinitionDescriptor Filter(IEnumerable<Elastic.Clients.Elasticsearch.Analysis.TokenFilter>? filter)
		{
			FilterValue = filter;
			return Self;
		}

		public CategorizationAnalyzerDefinitionDescriptor Tokenizer(Elastic.Clients.Elasticsearch.Analysis.Tokenizer? tokenizer)
		{
			TokenizerValue = tokenizer;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (CharFilterValue is not null)
			{
				writer.WritePropertyName("char_filter");
				JsonSerializer.Serialize(writer, CharFilterValue, options);
			}

			if (FilterValue is not null)
			{
				writer.WritePropertyName("filter");
				JsonSerializer.Serialize(writer, FilterValue, options);
			}

			if (TokenizerValue is not null)
			{
				writer.WritePropertyName("tokenizer");
				JsonSerializer.Serialize(writer, TokenizerValue, options);
			}

			writer.WriteEndObject();
		}
	}
}